﻿using System;
using System.Collections.Generic;
using System.Text;

namespace T.FAS.Runtime.Metadata.Entity
{
    public class MetaDataUpdateItem
    {
        /// <summary>
        /// 变更枚举
        /// </summary>
        public MetaUpdateType UpdateType { get; set; }
        /// <summary>
        /// 变更枚举中文名称
        /// </summary>
        public string UpdateTypeName { get; set; }
        /// <summary>
        /// 依赖更新变更类型
        /// </summary>
        public DependencyChangeType OperateType { get {
                if (NewValue != null && OldValue != null)
                {
                    return DependencyChangeType.Update;
                }
                else if (NewValue != null)
                {
                    return DependencyChangeType.New;
                }
                else if (OldValue != null) {
                    return DependencyChangeType.Delete;
                }
                return DependencyChangeType.None;
            } 
        }

        public object NewValue { get; set; }

        public object OldValue { get; set; }

        public bool UpdateResult { get; set; } = true;
        public string FailMessage { get; set; }
        #region 预留
        public string UpdateKey { get; set; }
        public string NewValueType { get; set; }
        public string OldValueType { get; set; }
        #endregion
        /// <summary>
        /// 变更是否可人工忽略
        /// </summary>
        public bool UpdateIsCanIgnore { get; set; } = true;
        /// <summary>
        /// 变更处理类型（0：系统自动处理，1:人工处理，2：人工忽略）
        /// </summary>
        public int UpdateResultType { get; set; } = 0;

    }
    /// <summary>
    /// 依赖更新变更类型
    /// </summary>
    public enum DependencyChangeType
    {
        /// <summary>
        /// 更新
        /// </summary>
        Update = 0,
        /// <summary>
        /// 新增
        /// </summary>
        New = 1,
        /// <summary>
        /// 删除
        /// </summary>
        Delete = 2,
        /// <summary>
        /// 
        /// </summary>
        None = -1
    }
}
